#include <iostream>


class Person {
public:
    int a;
    int b;

public:
    Person operator+(Person &p) {
        Person temp{};
        temp.a = this->a + p.a;
        temp.b = this->b + p.b;
        return temp;
    }
};

// 全局函数重载+号
Person operator+(Person &p1, Person &p2) {
    Person temp{};
    temp.a = p1.a + p2.a;
    temp.b = p1.b + p2.b;
    return temp;
}

// 函数重载版本
Person operator+(Person &p1, int num) {

}

void test01() {
    Person p1;
    p1.a = 10;
    p1.b = 10;

    Person p2;
    p2.a = 10;
    p2.b = 10;

    // 成员函数重载本质的调用
    Person p3 = p1.operator+(p2);

    // 全局函数重载本质调用
    Person p4 = operator+(p1, p2);

//    Person p3 = p1 + p2;

    std::cout << p3.a << std::endl;
    std::cout << p3.b << std::endl;
}
int main() {
    test01();
    return 0;
}

